<%-- 
    Document   : CMS_movieInformation
    Created on : Dec 1, 2013, 12:34:38 PM
    Author     : BibooChung
--%>


<!DOCTYPE html>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import = "java.util.*" import="cart.hibernate.releaseCompany.*, cart.hibernate.movieInformation.*" import="cart.*,java.net.*,java.text.*" %>
<%@page import="cart.hibernate.coverImage.*, cart.hibernate.rating.*, cart.hibernate.order.*, cart.hiberate.genre.*, cart.hibernate.actor.*" %> 
<jsp:useBean id = "releaseCompanyManager" scope= "request" class = "cart.hibernate.releaseCompany.ReleaseCompany" />
<jsp:useBean id = "movieInformationManager" scope= "request" class = "cart.hibernate.movieInformation.ManageMovieInformation" />

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Manage MovieInformation
    </h1>

        <!-- Table with integrated management -->
        <table border="0" style="border-color:black;margin-bottom:20px;">
                <tr>
                    <th>MovieInformation
                 ID</th>
                    <th>Password</th>
                    <th>Email</th>
                    <th>Gender</th>
                    <th>HomePhoneNumber</th>
                    <th>CellPhoneNumber</th>
                    <th>BirthDate</th>
                    <th>JoinDate</th>
                    <th>NickName</th>
                    <th>Point</th>
                    <th>FirstName</th>
                    <th>MiddleName</th>
                    <th>LastName</th>
                    <th>MovieInformation</th>
                    <th>Orders</th>
                    <th>Update?</th>
                    <th>Delete?</th>
                </tr>
                <%
                    List movieInformationList = movieInformationManager.getAllMovieInformation
                ();
                    List releaseCompanyList = releaseCompanyManager.getAllMovieInformation
                shipTier();
                    //List orderList = orderManager.getAllOrder();

                    Iterator iterMovieInformation
                 = movieInformationList.iterator();
                    Iterator iterMovieInformation
                shipTier = releaseCompanyList.iterator();

                    while (iterMovieInformation
                    .hasNext())
                    {

                        MovieInformation
                     movieInformation = (MovieInformation
                        ) iterMovieInformation
                    .next();
                %>
                        <tr>
                        <table>
                            <form action="ManageMovieInformation
                        Servlet" method="post">
                                <input type="hidden" name="loginName" value="<%= movieInformation.getLoginName() %>"> 
                                <td>
                                    <%= movieInformation.getLoginName() %>
                                </td>
                                <td>
                                    <input type="text" name="password" value="<%= movieInformation.getPassword() %>" />
                                </td>
                                <td>
                                    <input type="text" name="email" value="<%= movieInformation.getEmail() %>" />
                                </td>
                                <td>
                                    <select name="gender">
                                        <option value="male" <% if(movieInformation.getGender() == 'M') out.print("selected='selected'");%> >
                                            M
                                        </option>
                                        <option value="female" <% if(movieInformation.getGender() == 'F') out.print("selected='selected'");%> >
                                            F
                                        </option>
                                    </select>
                                </td>
                                <td>
                                    <input type="text" name="homePhoneNumber" value="<%= movieInformation.getHomePhoneNumber() %>" />
                                </td>
                                <td>
                                    <input type="text" name="cellPhoneNumber" value="<%= movieInformation.getCellPhoneNumber() %>" />
                                </td>
                                <td>
                                    <input type="date" name="birthDate" value="<%= movieInformation.getBirthDate() %>" />
                                </td>
                                <td>
                                    <input type="date" name="joinDate" value="<%= movieInformation.getJoinDate() %>" />
                                </td>
                                <td>
                                    <input type="text" name="nickName" value="<%= movieInformation.getNickName() %>" />
                                </td>
                                <td>
                                    <input type="text" name="point" value="<%= movieInformation.getPoint() %>" />
                                </td>
                                <td>
                                    <input type="text" name="firstName" value="<%= movieInformation.getFirstName() %>" />
                                </td>
                                <td>
                                    <input type="text" name="middleName" value="<%= movieInformation.getMiddleName() %>" />
                                </td>
                                <td>
                                    <input type="text" name="lastName" value="<%= movieInformation.getLastName() %>" />
                                </td>
                                <td>
                                    <select name="releaseCompanyId">
                                        <%
                                            while (iterMovieInformation
                                        shipTier.hasNext())
                                            {
                                                MovieInformation
                                            shipTier releaseCompany = (MovieInformation
                                            shipTier) iterMovieInformation
                                            shipTier.next();

                                                if(releaseCompany.getMovieInformation
                                            shipTierId() == movieInformation.getMovieInformation
                                            shipTier().getMovieInformation
                                            shipTierId())
                                                    out.print("<option value='" + releaseCompany.getMovieInformation
                                                shipTierId() + "' selected='selected'>" + releaseCompany.getMovieInformation
                                                shipTier() + "</option>");
                                                else
                                                    out.print("<option value='" + releaseCompany.getMovieInformation
                                                shipTierId() + "'>" + releaseCompany.getMovieInformation
                                                shipTier() + "</option>");
                                            }
                                            iterMovieInformation
                                        shipTier = releaseCompanyList.iterator();
                                        %>
                                    </select>
                                </td>
                                <td>
                                    <input type="text" name="password" value="Orders" />
                                </td>
                                <td>
                                    <input type="submit" name="submit" value="update">
                                </td>
                                <td>
                                    <input type="submit" name="submit" value="delete">
                                </td>
                            </form>
                        </table>
                        </tr>
                <%        
                    }
                %>
                    <tr>
                    <table>
                        <form action="ManageMovieInformation
                    Servlet" method="post">
                            <td>Enter new movieInformation : </td>
                            <td><input type="text" name="loginName" id="loginName"></td>
                            <td><input type="text" name="password" ></td>
                            <td><input type="text" name="email"/>
                            <td>
                                <select name="gender">
                                    <option value="male">M</option>
                                    <option value="female">F</option>
                                </select>
                            </td>
                            <td><input type="text" name="homePhoneNumber" /></td>
                            <td><input type="text" name="cellPhoneNumber" /></td>
                            <td><input type="date" name="birthDate" /></td>
                            <td><input type="date" name="joinDate" /></td>
                            <td><input type="text" name="nickName"  /></td>
                            <td><input type="text" name="point"  /></td>
                            <td><input type="text" name="firstName"  /></td>
                            <td><input type="text" name="middleName"  /></td>
                            <td><input type="text" name="lastName" /></td>
                            <td>
                                <select name="releaseCompanyId">
                                    <%
                                        while (iterMovieInformation
                                        shipTier.hasNext())
                                        {
                                            MovieInformation
                                        shipTier releaseCompany = (MovieInformation
                                        shipTier) iterMovieInformation
                                        shipTier.next();
                                            out.print("<option value='" + releaseCompany.getMovieInformation
                                        shipTierId() + "'>" + releaseCompany.getMovieInformation
                                        shipTier() + "</option>");
                                        }
                                        iterMovieInformation
                                    shipTier = releaseCompanyList.iterator();
                                    %>
                                </select>
                            </td>
                            <td><input type="text" name="order" /></td>
                            <td><input type="submit" name="submit" value="add"></td>
                        </form>
                    </table>
                    </tr>
        </table>
    </body>
</html>
